<template>
  <div class="student">
    <h2 class="atguigu">欢迎！</h2>
    <h2 @click="showName">学生姓名：{{ name }}</h2>
    <h2>学生性别：{{ gender }}</h2>
    <h2>学生年龄：{{ age }}</h2>
    <button @click="sendStudentName(name)">把学生姓名给School</button>
  </div>
</template>

<script>
// 局部混合
import {showName} from "@/mixins";

export default {
  name: "Student",
  data() {
    return {
      name: "张三",
      gender: "男",
      age: 18
    }
  },
  computed: {},
  components: {},
  methods: {
    ageAdd(){
      console.log('ageAdd');
      this.age++;
    },
    sendStudentName(name) {
      this.$bus.$emit('hello', name);
    },
    unbindAtguigu(){
      // 解绑一个自定义事件
      // this.$off('atguigu');

      // 解绑多个自定义事件
      // this.$off(['atguigu', 'demo']);

      // 解绑所有自定义事件
      this.$off();
    },
    death(){
      this.$destroy();
    }
  },
  mixins: [showName],
  watch: {},
  filters: {},
  directives: {}
}
</script>

<style scoped lang="less">
.student {
  background-color: pink;
  padding: 5px;
  margin-top: 30px;

  .atguigu {
    font-size: 40px;
  }
}
</style>